import request from '/@/request/https'
import { AxiosPromise } from 'axios'

export interface submitParam {
    credential: string
}
export interface moduleInfo {
    id: string,
    userId: string,
    type: string,
    modelEntryTime:string,
    modelExitTime: string,
    modelName:string,
    phoneSystem:string
}

export function moduleChange(data:moduleInfo):AxiosPromise { // 记录行为日志
    return request({
        url: `/behavior/services/moduleChange`,
        method: 'post',
        data: data
    })
}
export function commonDict(type:string):AxiosPromise { // 数据字典 接口
    return request({
        url: `/jstservice/common/dict`,
        method: 'post',
        data:{
            codeType: type
        }
    })
}

export function userInfo(transactionId:string):AxiosPromise { // 通过 transactionId 获取用户信息
    return request({
        url: `/review-auth/v2/authorization/${transactionId}/user/info`,
        method: 'get'
    })
}

export function tokenInfo():AxiosPromise { // token未失效时 获取脱敏的用户信息
    return request({
        url: `/review-auth/v2/token/info`,
        method: 'post'
    })
}
export function tokenRefresh():AxiosPromise { // 刷新token
    return request({
        url: `/review-auth/v2/token/refresh`,
        method: 'post'
    })
}

export function tokenReissue(smsCode:string):AxiosPromise { // 重新签发token
    return request({
        url: `/review-auth/v2/token/reissue?smsCode=${smsCode}`,
        method: 'post'
    })
}

export function tokenSms():AxiosPromise { // 发送手机验证码
    return request({
        url: `/review-auth/v2/token/sms`,
        method: 'post'
    })
}



export function refreshApi(redirectUri?:string):AxiosPromise { // 功能 不传事物id的刷新
    return request({
        url: `/review-auth/v2/token/refresh?redirectUri=${redirectUri}`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}token/refresh?redirectUri=${redirectUri}`,
        method: 'post'
    })
}

export function renewalApi(transactionId:string):AxiosPromise {
    return request({
        url: `/review-auth/v2/authorization/${transactionId}/renewal`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/renewal`,
        method: 'post'
    })
}
export function subMobile(transactionId:string, param: submitParam): AxiosPromise { // 提交手机号的
    return request({
        url: `/review-auth/v2/authorization/${transactionId}/mobile`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/mobile`,
        method: 'post',
        data: {
            credential: param.credential
           
        }
    })
}

export function userSubmit(param: string): AxiosPromise { // 提交手机号，姓名，证件号
    return request({
        url: `/v2/authorization/sms`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/mobile`,
        method: 'post',
        data: {
            credential: param
           
        }
    })
}

export function sendSms(transactionId:string): AxiosPromise {
    return request({
        url: `/review-auth/v2/authorization/${transactionId}/sms`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/sms`,
        method: 'post'
    })
}
export function subCode( param: string):AxiosPromise {
    return request({
        // url:`/review-auth/v2/authorization/${transactionId}/sms/code`,
        url:`/v2/authorization/sms/code`,
        // url:`${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/sms/code`,
        method: 'post',
        data:  param
        
           
           
        
    })
}
export function subFace(param: submitParam):AxiosPromise {
    return request({
        url:`/v2/authorization/face`,
        // url:`${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/face`,
        method: 'post',
        data:param
    })
}
export function CustomerInfoByTaskCode(data:any):AxiosPromise {
    return request({
        url:`/push/getCustomerInfoByTaskCode`,
        method: 'post',
        data
    })
}
export function agreementStatusApi():AxiosPromise { // 查看需要展示的协议
    return request({
        url: `/review-auth/v2/agreement/status`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}agreement/status`,
        method: 'get'
    })
}
export function agreementContent(agreementType:string):AxiosPromise {// 查询相关的协议内容    
    return request({
        url: `/review-auth/v2/agreement/content/${agreementType}`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}agreement/content/${agreementType}`,
        method: 'get'
    })
}
export function sureAgreement(agreementTypes:string):AxiosPromise { // 提交同意的协议  
    return request({
        url: `/review-auth/v2/agreement/status/${agreementTypes}`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}agreement/status/${agreementType}`,
        method: 'post'
    })
}
export function callbackApi(transactionId:string):AxiosPromise { // 登录成功的回调  
    return request({
        url: `/review-auth/v2/authorization/${transactionId}/callback`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}authorization/${transactionId}/callback`,
        method: 'get'
    })
}

export function getStatement(transactionId:string):AxiosPromise { // 获取授权协议全文
    return request({
        url: `/review-auth/v2/statement/${transactionId}/statement`,
        method: 'get'
    })
}
export function statementInfo(transactionId:string):AxiosPromise { // 获取授权协议页信息
    return request({
        url: `/review-auth/v2/statement/${transactionId}/info`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}client/statement/personalInfo/${transactionId}/info`,
        method: 'get'
    })
}
export function statementAcceptance(transactionId:string):AxiosPromise { // 授权协议同意接口
    return request({
        url: `/review-auth/v2/statement/${transactionId}/acceptance`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}client/statement/personalInfo/${transactionId}/acceptance`,
        method: 'post'
    })
}


export interface submitParam {
    credential: string
}
export interface moduleInfo {
    id: string,
    userId: string,
    type: string, 
    modelEntryTime:string,
    modelExitTime: string,
    modelName:string, 
    phoneSystem:string
}
export function RInform(taskNo:string):AxiosPromise { // 获取告知页的地址
    return request({
        url: `/review/v2/home/info/${taskNo}`,
        method: 'get'
    }) 
}
export function RStatementInfo(statementId:string):AxiosPromise { // 获取授权页面的协议信息
    return request({
        url: `/review/v2/statement/info/${statementId}`,
        method: 'get'
    }) 
}

export function RAcceptance(params:object):AxiosPromise { // 同意授权页面的协议
    return request({
        url: `/review/v2/statement/acceptance`,
        method: 'post',
        data:params
    }) 
}
export function RAuthorization(taskCode:string,path:string):AxiosPromise { // 入口认证从定向接口
    return request({
        url: `/review/v2/authorization?taskCode=${taskCode}&path=${path}`,
        method: 'post'
    }) 
}
export function RLogFace(taskNo:string):AxiosPromise { // 人脸之后的日志接口
    return request({
        url: `/review/v2/customer/log/face/${taskNo}`,
        method: 'post'
    }) 
} 
export function stateNotification(taskNo:string):AxiosPromise { // 人脸之后的日志接口
    return request({
        url: `/v2/customer/stateNotification`,
        method: 'post',
        data: {
            taskCode: taskNo
        }
    }) 
} 
export function list(taskNo:string):AxiosPromise { // 获取保单检视列表接口
    return request({
        url: `/review/v2/insurance/list?taskNo=${taskNo}`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}certificate/qr`,
        method: 'get'
    }) 
}
export function report(taskNo:string, params:Array<string>):AxiosPromise { // 获取生成报告的接口地址
    return request({
        url: `/review/v2/insurance/report?taskNo=${taskNo}`,
        // url: `${import.meta.env.VITE_APP_API_URL || ''}certificate/qr`,
        method: 'post',
        data: {
            policyNo: params
        }
    }) 
}